package com.example.design.behavior.state.enums;

import lombok.Getter;

/**
 * \* @author: bear
 * \* Date: 2021-01-22-10:31
 * \* describe:
 */

public enum State implements IState{

	new_built("new"){
		@Override
		public State start() {
			System.out.println("启动线程，启动后变为就绪");
			return READY;
		}
	},
	READY("ready"){
		@Override
		public State getCpu() {
			System.out.println("就绪状态getCPU,变成运行状态");
			return RUNNING;
		}
	},
	RUNNING("running"){
		@Override
		public State stop() {
			System.out.println("当前状态stop后，变为dead状态");
			return DEAD;
		}

		@Override
		public State suspend() {
			System.out.println("当前状态suspend后，变为阻塞状态");
			return BLOCK;
		}
	},
	BLOCK("blocking"){
		@Override
		public State start() {
			System.out.println("当前状态经过resume后，变成就绪状态readyState");
			return READY;
		}
	},
	DEAD("dead");

	private String stateName;
	State(String stateName){
		this.stateName = stateName;
	}
	@Override
	public State start() {
		System.out.println("当前状态，不可以start");
		return null;
	}

	@Override
	public State getCpu() {
		System.out.println("当前状态，不可以getCpu");
		return null;
	}

	@Override
	public State stop() {
		System.out.println("当前状态，不可以stop");
		return null;
	}

	@Override
	public State resume() {
		System.out.println("当前状态，不可以resume");
		return null;
	}

	@Override
	public State suspend() {
		System.out.println("当前状态，不可以suspend");
		return null;
	}
}
